package IO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class IO11 {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("./test.txt")){
            while(true){
                byte[] buffer  = new byte[1024];
                //n返回值表示read实际读取到
                int n = inputStream.read(buffer);
                if(n==-1){
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.printf("0x%x\n",buffer[i]);
                }
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
